package com.web.zsqqimengzhixing.mapper;

import com.web.zsqqimengzhixing.pojo.Articles;
import com.web.zsqqimengzhixing.pojo.Comments;
import com.web.zsqqimengzhixing.pojo.Upvotes;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ArticlesMapper {

    @Select("select * from articles")
    List<Articles> select();

    @Insert("insert into articles(userid,publish_content,publish_time,plate) values(#{userid},#{publishContent},#{publishTime},#{plate})")
    void insert(Articles articles);

    @Insert("insert into comments(userid,article_id,comment_content,comment_time) VALUES(#{userid},#{articleId},#{commentContent},#{commentTime})")
    void insertcom(Comments comments);

    @Select("select * from comments where article_id=#{articleId}")
    List<Comments> selectcom(Integer articleId);

    @Insert("insert into upvotes(userid,article_id,up_time) values(#{userid},#{articleId},#{upTime})")
    void upvotes(Upvotes upvotes);

    @Select("select * from upvotes where article_id=#{articleId}")
    List<Upvotes> selectupvotes(Integer articleId);
}
